<!-- views/login/UserTypeCard.vue -->
<template>
  <div class="user-type-container">
    <el-radio-group v-model="selectedType" class="user-type-group">
      <el-radio-button
          v-for="type in userTypes"
          :key="type.value"
          :label="type.value"
          class="user-type-card"
      >
        <div class="card-content">
          <div class="icon-wrapper">
            <component :is="type.icon" class="type-icon" />
          </div>
          <div class="type-label">{{ type.label }}</div>
        </div>
      </el-radio-button>
    </el-radio-group>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue';
import {
  User,
  School,
  Setting
} from '@element-plus/icons-vue';

const props = defineProps({
  modelValue: {
    type: String,
    default: null
  }
});

const emit = defineEmits(['update:modelValue']);

const selectedType = computed({
  get: () => props.modelValue,
  set: (value) => emit('update:modelValue', value)
});

const userTypes = [
  { value: 'student', label: '学生', icon: User },
  { value: 'teacher', label: '教师', icon: School },
  // { value: 'admin', label: '管理员', icon: Setting }
];
</script>

<style scoped>
.user-type-container {
  margin: 20px 0;
}

.user-type-group {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.user-type-card {
  flex: 1;
  margin: 0 5px;
  height: auto;
  border-radius: 8px;
  overflow: hidden;
}

:deep(.el-radio-button__inner) {
  display: block;
  padding: 20px 10px;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

:deep(.el-radio-button__original-radio:checked + .el-radio-button__inner) {
  background-color: #f0f7ff;
  border-color: #409eff;
  color: #409eff;
  box-shadow: 0 2px 12px rgba(64, 158, 255, 0.2);
}

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.type-icon {
  width: 30px;
  height: 30px;
  color: #409eff;
}

.type-label {
  font-size: 14px;
  font-weight: 500;
}
</style>
